home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / doom / quake_ad.zip / RESPAWN.ZIP / SRC / WIZARD.QC < prev   
Text File  |  1997-03-16  |  13KB  |  456 lines

  1. /*
  2. ==============================================================================
  3.  
  4. WIZARD
  5.  
  6. ==============================================================================
  7. */
  8.  
  9. $cd id1/models/a_wizard
  10. $origin 0 0 24
  11. $base wizbase    
  12. $skin wizbase
  13.  
  14. $frame hover1 hover2 hover3 hover4 hover5 hover6 hover7 hover8
  15. $frame hover9 hover10 hover11 hover12 hover13 hover14 hover15
  16.  
  17. $frame fly1 fly2 fly3 fly4 fly5 fly6 fly7 fly8 fly9 fly10
  18. $frame fly11 fly12 fly13 fly14
  19.  
  20. $frame magatt1 magatt2 magatt3 magatt4 magatt5 magatt6 magatt7
  21. $frame magatt8 magatt9 magatt10 magatt11 magatt12 magatt13
  22.  
  23. $frame pain1 pain2 pain3 pain4
  24.  
  25. $frame death1 death2 death3 death4 death5 death6 death7 death8
  26.  
  27. /*
  28. ==============================================================================
  29.  
  30. WIZARD
  31.  
  32. If the player moves behind cover before the missile is launched, launch it
  33. at the last visible spot with no velocity leading, in hopes that the player
  34. will duck back out and catch it.
  35. ==============================================================================
  36. */
  37.  
  38. /*
  39. =============
  40. LaunchMissile
  41.  
  42. Sets the given entities velocity and angles so that it will hit self.enemy
  43. if self.enemy maintains it's current velocity
  44. 0.1 is moderately accurate, 0.0 is totally accurate
  45. =============
  46. */
  47. void(entity missile, float mspeed, float accuracy) LaunchMissile =
  48. {
  49.     local    vector    vec, move;
  50.     local    float    fly;
  51.  
  52.     makevectors (self.angles);
  53.         
  54. // set missile speed
  55.     vec = self.enemy.origin + self.enemy.mins + self.enemy.size * 0.7 - missile.origin;
  56.  
  57. // calc aproximate time for missile to reach vec
  58.     fly = vlen (vec) / mspeed;
  59.     
  60. // get the entities xy velocity
  61.     move = self.enemy.velocity;
  62.     move_z = 0;
  63.  
  64. // project the target forward in time
  65.     vec = vec + move * fly;
  66.     
  67.     vec = normalize(vec);
  68.     vec = vec + accuracy*v_up*(random()- 0.5) + accuracy*v_right*(random()- 0.5);
  69.     
  70.     missile.velocity = vec * mspeed;
  71.  
  72.     missile.angles = '0 0 0';
  73.     missile.angles_y = vectoyaw(missile.velocity);
  74.  
  75. // set missile duration
  76.     missile.nextthink = time + 5;
  77.     missile.think = SUB_Remove;    
  78. };
  79.  
  80.  
  81. void() wiz_run1;
  82. void() wiz_side1;
  83. //--------------------------------------------------------- New Code --------
  84. void() wiz_death9;
  85. //---------------------------------------------------------------------------
  86.  
  87. /*
  88. =================
  89. WizardCheckAttack
  90. =================
  91. */
  92. float()    WizardCheckAttack =
  93. {
  94.     local vector    spot1, spot2;    
  95.     local entity    targ;
  96.     local float        chance;
  97.  
  98.     if (time < self.attack_finished)
  99.         return FALSE;
  100.     if (!enemy_vis)
  101.         return FALSE;
  102.  
  103.     if (enemy_range == RANGE_FAR)
  104.     {
  105.         if (self.attack_state != AS_STRAIGHT)
  106.         {
  107.             self.attack_state = AS_STRAIGHT;
  108.             wiz_run1 ();
  109.         }
  110.         return FALSE;
  111.     }
  112.         
  113.     targ = self.enemy;
  114.     
  115. // see if any entities are in the way of the shot
  116.     spot1 = self.origin + self.view_ofs;
  117.     spot2 = targ.origin + targ.view_ofs;
  118.  
  119.     traceline (spot1, spot2, FALSE, self);
  120.  
  121.     if (trace_ent != targ)
  122.     {    // don't have a clear shot, so move to a side
  123.         if (self.attack_state != AS_STRAIGHT)
  124.         {
  125.             self.attack_state = AS_STRAIGHT;
  126.             wiz_run1 ();
  127.         }
  128.         return FALSE;
  129.     }
  130.             
  131.     if (enemy_range == RANGE_MELEE)
  132.         chance = 0.9;
  133.     else if (enemy_range == RANGE_NEAR)
  134.         chance = 0.6;
  135.     else if (enemy_range == RANGE_MID)
  136.         chance = 0.2;
  137.     else
  138.         chance = 0;
  139.  
  140.     if (random () < chance)
  141.     {
  142.         self.attack_state = AS_MISSILE;
  143.         return TRUE;
  144.     }
  145.  
  146.     if (enemy_range == RANGE_MID)
  147.     {
  148.         if (self.attack_state != AS_STRAIGHT)
  149.         {
  150.             self.attack_state = AS_STRAIGHT;
  151.             wiz_run1 ();
  152.         }
  153.     }
  154.     else
  155.     {
  156.         if (self.attack_state != AS_SLIDING)
  157.         {
  158.             self.attack_state = AS_SLIDING;
  159.             wiz_side1 ();
  160.         }
  161.     }
  162.     
  163.     return FALSE;
  164. };
  165.  
  166. /*
  167. =================
  168. WizardAttackFinished
  169. =================
  170. */
  171. float()    WizardAttackFinished =
  172. {
  173.     if (enemy_range >= RANGE_MID || !enemy_vis)
  174.     {
  175.         self.attack_state = AS_STRAIGHT;
  176.         self.think = wiz_run1;
  177.     }
  178.     else
  179.     {
  180.         self.attack_state = AS_SLIDING;
  181.         self.think = wiz_side1;
  182.     }
  183. };
  184.  
  185. /*
  186. ==============================================================================
  187.  
  188. FAST ATTACKS
  189.  
  190. ==============================================================================
  191. */
  192.  
  193. void() Wiz_FastFire =
  194. {
  195.     local vector        vec;
  196.     local vector        dst;
  197.  
  198.     if (self.owner.health > 0)
  199.     {
  200.         self.owner.effects = self.owner.effects | EF_MUZZLEFLASH;
  201.  
  202.         makevectors (self.enemy.angles);    
  203.         dst = self.enemy.origin - 13*self.movedir;
  204.     
  205.         vec = normalize(dst - self.origin);
  206.         sound (self, CHAN_WEAPON, "wizard/wattack.wav", 1, ATTN_NORM);
  207.         launch_spike (self.origin, vec);
  208.         newmis.velocity = vec*600;
  209.         newmis.owner = self.owner;
  210.         newmis.classname = "wizspike";
  211.         setmodel (newmis, "progs/w_spike.mdl");
  212.         setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  213.     }
  214.  
  215.     remove (self);
  216. };
  217.  
  218.  
  219. void() Wiz_StartFast =
  220. {
  221.     local    entity    missile;
  222.     
  223.     sound (self, CHAN_WEAPON, "wizard/wattack.wav", 1, ATTN_NORM);
  224.     self.v_angle = self.angles;
  225.     makevectors (self.angles);
  226.  
  227.     missile = spawn ();
  228.     missile.owner = self;
  229.     missile.nextthink = time + 0.6;
  230.     setsize (missile, '0 0 0', '0 0 0');        
  231.     setorigin (missile, self.origin + '0 0 30' + v_forward*14 + v_right*14);
  232.     missile.enemy = self.enemy;
  233.     missile.nextthink = time + 0.8;
  234.     missile.think = Wiz_FastFire;
  235.     missile.movedir = v_right;
  236.  
  237.     missile = spawn ();
  238.     missile.owner = self;
  239.     missile.nextthink = time + 1;
  240.     setsize (missile, '0 0 0', '0 0 0');        
  241.     setorigin (missile, self.origin + '0 0 30' + v_forward*14 + v_right* -14);
  242.     missile.enemy = self.enemy;
  243.     missile.nextthink = time + 0.3;
  244.     missile.think = Wiz_FastFire;
  245.     missile.movedir = VEC_ORIGIN - v_right;
  246. };
  247.  
  248.  
  249.  
  250. void() Wiz_idlesound =
  251. {
  252. local float wr;
  253.     wr = random() * 5;
  254.  
  255.     if (self.waitmin < time)
  256.     {
  257.          self.waitmin = time + 2;
  258.          if (wr > 4.5) 
  259.              sound (self, CHAN_VOICE, "wizard/widle1.wav", 1,  ATTN_IDLE);
  260.          if (wr < 1.5)
  261.              sound (self, CHAN_VOICE, "wizard/widle2.wav", 1, ATTN_IDLE);
  262.     }
  263.     return;
  264. };
  265.  
  266. void()    wiz_stand1    =[    $hover1,        wiz_stand2    ] {ai_stand();};
  267. void()    wiz_stand2    =[    $hover2,        wiz_stand3    ] {ai_stand();};
  268. void()    wiz_stand3    =[    $hover3,        wiz_stand4    ] {ai_stand();};
  269. void()    wiz_stand4    =[    $hover4,        wiz_stand5    ] {ai_stand();};
  270. void()    wiz_stand5    =[    $hover5,        wiz_stand6    ] {ai_stand();};
  271. void()    wiz_stand6    =[    $hover6,        wiz_stand7    ] {ai_stand();};
  272. void()    wiz_stand7    =[    $hover7,        wiz_stand8    ] {ai_stand();};
  273. void()    wiz_stand8    =[    $hover8,        wiz_stand1    ] {ai_stand();};
  274.  
  275. void()    wiz_walk1    =[    $hover1,        wiz_walk2    ] {ai_walk(8);
  276. Wiz_idlesound();};
  277. void()    wiz_walk2    =[    $hover2,        wiz_walk3    ] {ai_walk(8);};
  278. void()    wiz_walk3    =[    $hover3,        wiz_walk4    ] {ai_walk(8);};
  279. void()    wiz_walk4    =[    $hover4,        wiz_walk5    ] {ai_walk(8);};
  280. void()    wiz_walk5    =[    $hover5,        wiz_walk6    ] {ai_walk(8);};
  281. void()    wiz_walk6    =[    $hover6,        wiz_walk7    ] {ai_walk(8);};
  282. void()    wiz_walk7    =[    $hover7,        wiz_walk8    ] {ai_walk(8);};
  283. void()    wiz_walk8    =[    $hover8,        wiz_walk1    ] {ai_walk(8);};
  284.  
  285. void()    wiz_side1    =[    $hover1,        wiz_side2    ] {ai_run(8);
  286. Wiz_idlesound();};
  287. void()    wiz_side2    =[    $hover2,        wiz_side3    ] {ai_run(8);};
  288. void()    wiz_side3    =[    $hover3,        wiz_side4    ] {ai_run(8);};
  289. void()    wiz_side4    =[    $hover4,        wiz_side5    ] {ai_run(8);};
  290. void()    wiz_side5    =[    $hover5,        wiz_side6    ] {ai_run(8);};
  291. void()    wiz_side6    =[    $hover6,        wiz_side7    ] {ai_run(8);};
  292. void()    wiz_side7    =[    $hover7,        wiz_side8    ] {ai_run(8);};
  293. void()    wiz_side8    =[    $hover8,        wiz_side1    ] {ai_run(8);};
  294.  
  295. void()    wiz_run1    =[    $fly1,        wiz_run2    ] {ai_run(16);
  296. Wiz_idlesound();
  297. };
  298. void()    wiz_run2    =[    $fly2,        wiz_run3    ] {ai_run(16);};
  299. void()    wiz_run3    =[    $fly3,        wiz_run4    ] {ai_run(16);};
  300. void()    wiz_run4    =[    $fly4,        wiz_run5    ] {ai_run(16);};
  301. void()    wiz_run5    =[    $fly5,        wiz_run6    ] {ai_run(16);};
  302. void()    wiz_run6    =[    $fly6,        wiz_run7    ] {ai_run(16);};
  303. void()    wiz_run7    =[    $fly7,        wiz_run8    ] {ai_run(16);};
  304. void()    wiz_run8    =[    $fly8,        wiz_run9    ] {ai_run(16);};
  305. void()    wiz_run9    =[    $fly9,        wiz_run10    ] {ai_run(16);};
  306. void()    wiz_run10    =[    $fly10,        wiz_run11    ] {ai_run(16);};
  307. void()    wiz_run11    =[    $fly11,        wiz_run12    ] {ai_run(16);};
  308. void()    wiz_run12    =[    $fly12,        wiz_run13    ] {ai_run(16);};
  309. void()    wiz_run13    =[    $fly13,        wiz_run14    ] {ai_run(16);};
  310. void()    wiz_run14    =[    $fly14,        wiz_run1    ] {ai_run(16);};
  311.  
  312. void()    wiz_fast1    =[    $magatt1,        wiz_fast2    ] {ai_face();Wiz_StartFast();};
  313. void()    wiz_fast2    =[    $magatt2,        wiz_fast3    ] {ai_face();};
  314. void()    wiz_fast3    =[    $magatt3,        wiz_fast4    ] {ai_face();};
  315. void()    wiz_fast4    =[    $magatt4,        wiz_fast5    ] {ai_face();};
  316. void()    wiz_fast5    =[    $magatt5,        wiz_fast6    ] {ai_face();};
  317. void()    wiz_fast6    =[    $magatt6,        wiz_fast7    ] {ai_face();};
  318. void()    wiz_fast7    =[    $magatt5,        wiz_fast8    ] {ai_face();};
  319. void()    wiz_fast8    =[    $magatt4,        wiz_fast9    ] {ai_face();};
  320. void()    wiz_fast9    =[    $magatt3,        wiz_fast10    ] {ai_face();};
  321. void()    wiz_fast10    =[    $magatt2,        wiz_run1    ] {ai_face();SUB_AttackFinished(2);WizardAttackFinished ();};
  322.  
  323. void()    wiz_pain1    =[    $pain1,        wiz_pain2    ] {};
  324. void()    wiz_pain2    =[    $pain2,        wiz_pain3    ] {};
  325. void()    wiz_pain3    =[    $pain3,        wiz_pain4    ] {};
  326. void()    wiz_pain4    =[    $pain4,        wiz_run1    ] {};
  327.  
  328. //--------------------------------------------------------- New Code --------
  329. //  The scrag has risen!
  330. //---------------------------------------------------------------------------
  331. void()  wiz_revive1     =[      $death8,        wiz_revive3     ]
  332. {       self.nextthink = self.nextthink + PM_SleepTime();
  333.         self.health = 0;
  334. };
  335. void()  wiz_revive2     =[      $death8,        wiz_revive3    ]
  336. {       self.nextthink = self.nextthink + 5;    };
  337. void()  wiz_revive3     =[      $death8,        wiz_revive4    ]
  338. {       // see if ok to stand up
  339.         self.health = 80;
  340.         sound (self, CHAN_VOICE, "wizard/widle2.wav", 1, ATTN_IDLE);
  341.         self.solid = SOLID_SLIDEBOX;
  342.         if (!walkmove (0, 0))
  343.         {       self.think = wiz_revive2;
  344.                 self.solid = SOLID_NOT;
  345.                 return;
  346.         }
  347. };
  348. void()  wiz_revive4    =[      $death7,        wiz_revive5     ] {};
  349. void()  wiz_revive5    =[      $death6,        wiz_revive6     ] {};
  350. void()  wiz_revive6    =[      $death5,        wiz_revive7     ] {};
  351. void()  wiz_revive7    =[      $death4,        wiz_revive8     ]
  352. {       self.velocity_z = self.velocity_z + 300;
  353.     if (self.flags & FL_ONGROUND)
  354.         self.flags = self.flags - FL_ONGROUND;
  355. };
  356. void()  wiz_revive8    =[      $death3,        wiz_revive9     ] {};
  357. void()  wiz_revive9    =[      $death2,        wiz_revive10    ] {};
  358. void()  wiz_revive10   =[      $death1,        wiz_run1        ]
  359. {       self.flags = self.flags | FL_FLY;
  360.         self.takedamage = DAMAGE_AIM;
  361. };
  362. //---------------------------------------------------------------------------
  363.  
  364. void()    wiz_death1    =[    $death1,        wiz_death2    ] {
  365.  
  366. self.velocity_x = -200 + 400*random();
  367. self.velocity_y = -200 + 400*random();
  368. self.velocity_z = 100 + 100*random();
  369. self.flags = self.flags - (self.flags & FL_ONGROUND);
  370. sound (self, CHAN_VOICE, "wizard/wdeath.wav", 1, ATTN_NORM);
  371. };
  372. void()    wiz_death2    =[    $death2,        wiz_death3    ] {};
  373. void()    wiz_death3    =[    $death3,        wiz_death4    ]{self.solid = SOLID_NOT;};
  374. void()    wiz_death4    =[    $death4,        wiz_death5    ] {};
  375. void()    wiz_death5    =[    $death5,        wiz_death6    ] {};
  376. void()    wiz_death6    =[    $death6,        wiz_death7    ] {};
  377. void()    wiz_death7    =[    $death7,        wiz_death8    ] {};
  378. //--------------------------------------------------------- Code Change -----
  379. void()  wiz_death8 =
  380. {       if (PM_Revive())  wiz_revive1();
  381.         else  wiz_death9();
  382. };
  383. void()  wiz_death9      =[      $death8,                wiz_death8      ] {};
  384. //---------------------------------------------------------------------------
  385.  
  386. void() wiz_die =
  387. {
  388. // check for gib
  389.     if (self.health < -40)
  390.     {
  391.         sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
  392.         ThrowHead ("progs/h_wizard.mdl", self.health);
  393.         ThrowGib ("progs/gib2.mdl", self.health);
  394.         ThrowGib ("progs/gib2.mdl", self.health);
  395.         ThrowGib ("progs/gib2.mdl", self.health);
  396.         return;
  397.     }
  398.  
  399.     wiz_death1 ();
  400. };
  401.  
  402.  
  403. void(entity attacker, float damage) Wiz_Pain =
  404. {
  405.     sound (self, CHAN_VOICE, "wizard/wpain.wav", 1, ATTN_NORM);
  406.     if (random()*70 > damage)
  407.         return;        // didn't flinch
  408.  
  409.     wiz_pain1 ();
  410. };
  411.  
  412.  
  413. void() Wiz_Missile =
  414. {
  415.     wiz_fast1();
  416. };
  417.  
  418. /*QUAKED monster_wizard (1 0 0) (-16 -16 -24) (16 16 40) Ambush
  419. */
  420. void() monster_wizard =
  421. {
  422.     if (deathmatch)
  423.     {
  424.         remove(self);
  425.         return;
  426.     }
  427.     precache_model ("progs/wizard.mdl");
  428.     precache_model ("progs/h_wizard.mdl");
  429.     precache_model ("progs/w_spike.mdl");
  430.  
  431.     precache_sound ("wizard/hit.wav");        // used by c code
  432.     precache_sound ("wizard/wattack.wav");
  433.     precache_sound ("wizard/wdeath.wav");
  434.     precache_sound ("wizard/widle1.wav");
  435.     precache_sound ("wizard/widle2.wav");
  436.     precache_sound ("wizard/wpain.wav");
  437.     precache_sound ("wizard/wsight.wav");
  438.  
  439.     self.solid = SOLID_SLIDEBOX;
  440.     self.movetype = MOVETYPE_STEP;
  441.  
  442.     setmodel (self, "progs/wizard.mdl");
  443.  
  444.     setsize (self, '-16 -16 -24', '16 16 40');
  445.     self.health = 80;
  446.  
  447.     self.th_stand = wiz_stand1;
  448.     self.th_walk = wiz_walk1;
  449.     self.th_run = wiz_run1;
  450.     self.th_missile = Wiz_Missile;
  451.     self.th_pain = Wiz_Pain;
  452.     self.th_die = wiz_die;
  453.         
  454.     flymonster_start ();
  455. };
  456.